package com.fenghongzhang.two;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private ListView lv;

    private static final String TAG = "MainActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        lv = (ListView) findViewById(R.id.lv);


        //集合中的数据,从哪里来.
        //通过内容解析者去读
        ContentResolver contentResolver = getContentResolver();

        List<String> list = new ArrayList<>();

//        list.add("http://img5.imgtn.bdimg.com/it/u=1831321739,3083785234&fm=26&gp=0.jpg");
//        list.add("http://img5.imgtn.bdimg.com/it/u=1831321739,3083785234&fm=26&gp=0.jpg");
//        //http://
        Uri uri = Uri.parse("content://com.feng.table2");

        Cursor query = contentResolver.query(uri, null, null, null, null);


        if(query != null){
            while(query.moveToNext()){
                String path = query.getString(query.getColumnIndex("path"));
                list.add(path);
            }
            query.close();
        }

        Log.i(TAG, "onCreate: "+list.size());


        MyAdapter myAdapter = new MyAdapter(this, list);
        lv.setAdapter(myAdapter);


    }
}
